﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Data.SqlClient;

namespace TextMIS
{
    public partial class frmMain : Form
    {

        public static string PersonRight;
        public static string userName;
        public frmMain()
        {
            InitializeComponent();
        }

        SqlConnection conn;
  //    SqlCommand com;
        SqlDataAdapter da;

        private void 个人信息登记ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            userName = frmLogin.userName;
         da = new SqlDataAdapter("select * from PatientInfo where Username='" + userName + "' and RegisterID > 0", conn);
            DataSet ds = new DataSet();
            if (conn.State == ConnectionState.Closed)
            {
                conn.Open();
            }
            da.Fill(ds, "PatientInfo");
            conn.Close();
            if (ds.Tables["PatientInfo"].Rows.Count == 0)
            {
                frmFillIn frmfi = new frmFillIn();
                frmfi.Show();
            }
            else
            { MessageBox.Show("你已经填写过相关信息！"); }
        }

        private void frmMain_Load(object sender, EventArgs e)
        {
            timer1.Start();
            conn = new
             SqlConnection(frmLogin.SQLstr);
            tslRight.Text = frmLogin.userRight;

            PersonRight = frmLogin.userRight;
            if (PersonRight == "普通用户")
            {
                体检统计ToolStripMenuItem.Enabled = false;
                系统维护ToolStripMenuItem.Enabled = false;
                报表打印ToolStripMenuItem.Enabled = false;
                体检项管理ToolStripMenuItem.Enabled = false;
                体检结果录入ToolStripMenuItem.Enabled = false;
                体检医生查询ToolStripMenuItem.Enabled = false;
            }
            if (PersonRight == "体检医生")
            {
                系统维护ToolStripMenuItem.Enabled = false;
                个人信息登记ToolStripMenuItem.Enabled = false;
                预定体检项目ToolStripMenuItem.Enabled = false;
            }
            if (PersonRight == "系统管理员")
            {
                个人信息登记ToolStripMenuItem.Enabled = false;
            }

        }

        private void 个人信息修改ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (PersonRight == "普通用户")
            {
                frmInfoEdit frmie = new frmInfoEdit();
                frmie.Show();
            }
            if (PersonRight == "体检医生")
            {
                frmDocEdit frmde = new frmDocEdit();
                frmde.Show();
            }
            if (PersonRight == "系统管理员")
            {
                frmManEdit frmme = new frmManEdit();
                frmme.Show();
            }

        }

        private void 预定体检项目ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmBrowseItem frmbi = new frmBrowseItem();
            frmbi.Show();
        }

        private void 体检项管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmItem frmitem = new frmItem();
            frmitem.Show();
        }

        private void 体检费用查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmCostFind frmcf = new frmCostFind();
            frmcf.Show();
        }

        private void 体检结果查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmResultFind frmrf = new frmResultFind();
            frmrf.Show();
        }

        private void 体检医生查询ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDoctorFind frmdf = new frmDoctorFind();
            frmdf.Show();
        }

        private void 体检人数统计ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmAllPeople frmap = new frmAllPeople();
            frmap.Show();
        }

        private void 体检费用统计ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmTotalCost frmtc = new frmTotalCost();
            frmtc.Show();
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        private void 体检结果录入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmResultIn frmri = new frmResultIn();
            frmri.Show();
        }

        private void 数据导入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDataPutIn frmdpi = new frmDataPutIn();
            frmdpi.Show();
        }

        private void 数据导出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmPutOut frmpo = new frmPutOut();
            frmpo.Show();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            DateTime dt = DateTime.Now;
            string TempStr2 = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

            //labTime.Text = TempStr + "   " + TempStr2;
            tslTime.Text = TempStr2;
        }

        private void 报表打印ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmPrint frmp = new frmPrint();
            frmp.Show();
        }

    }
}
